package leetcode.part3;

import org.junit.Test;

public class S48 {
    public void rotate(int[][] matrix) {
        int n= matrix.length;
        // 上下翻转
        for (int i=0;i<n/2;i++){
            for (int j=0;j<n;j++){
                int tmp=matrix[i][j];
                matrix[i][j]=matrix[n-1-i][j];
                matrix[n-1-i][j]=tmp;
            }
        }

        // 左斜对角线翻转
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < i; j++) {
                int tmp=matrix[i][j];
                matrix[i][j]=matrix[j][i];
                matrix[j][i]=tmp;
            }
        }

    }

    @Test
    public void test(){
        int[][] matrix = {{5,1,9,11},{2,4,8,10},{13,3,6,7},{15,14,12,16}};
        rotate(matrix);
    }
}
